package org.NooLab.glue.msgframe;

import org.NooLab.glue.MessageBoard;

 
/**
 * 
 * 
 */
public abstract class MessageHandlerAbs implements Runnable{

	protected MessageBoard msgboard;
	
	protected 	boolean isRunning = false;
	protected   boolean isWorking = false;

	
	protected Thread thrd;
	protected String name ;	
	
	public MessageHandlerAbs( MessageBoard mb, String name ){
		
		msgboard = mb ;
		// srcMessages = mb.sourceMessages ;
		 
		thrd = new Thread(this,"MessageHandlerAbs()-"+name);
		 
		thrd.start() ;

	}
	
	
	abstract public void run();
	
	public void enforcedStop(){
		
		if (thrd != null){
			try {
				thrd.interrupt();
			} catch (Exception e) {
			}
			
			
			isRunning = false;
			isWorking = false;
		}
	}
	

	public boolean isRunning() {
		return isRunning;
	}
	
	public void startHandler(){
		thrd.start() ;
	}


	public boolean isWorking() {
		return isWorking;
	}
}
